package br.com.control;

import java.util.ArrayList;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonParser;

public class WS_TelaLista_laudo {
	// Url WEB SERVICE
	private static String URI = "http://192.168.1.135:8080";

	public ArrayList<ConsultaGeral> getListaJson() {
		ArrayList<ConsultaGeral> consultageral = new ArrayList<ConsultaGeral>();
		try {
			// Array de String que recebe o JSON do Web Service
			String[] json = new Webservice().get(URI
					+ "/SLLM-REST(WebService)/SLLM/getlistaConsultageral");

			if (json[0].equals("200")) {

				Gson gson = new Gson();

				JsonParser parser = new JsonParser();
				// convertendo para um json Array
				JsonArray array = parser.parse(json[1]).getAsJsonArray();
				for (int i = 0; i < array.size(); i++) {
					consultageral.add(gson.fromJson(array.get(i),
							ConsultaGeral.class));
				}

			}

		}

		catch (Exception e) {
			e.printStackTrace();
		}
		return consultageral;
	}
}
